package com.cyzy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyzy.mapper.BannerMapper;
import com.cyzy.pojo.Banner;
import com.cyzy.service.BannerService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements BannerService {

    @Override
    public List<Banner> getAdoptBanners() {
        // 查询条件：banner_type为"认养" 且 product_id为-2 且 banner_status为1(正常)
        LambdaQueryWrapper<Banner> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Banner::getBannerType, "认养")
                    .eq(Banner::getProductId, -2)
                    .eq(Banner::getBannerStatus, 1)
                    .orderByAsc(Banner::getSort);  // 按sort字段升序排序
        
        return this.list(queryWrapper);
    }
} 